package com.djc8.controller;

import java.io.IOException;
import java.text.ParseException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.djc8.entity.UserInfoBean;
import com.djc8.model.Model;

/**
 * Servlet implementation class UserLoginExitServlet
 */
public class UserLoginExitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public UserLoginExitServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	
			if ((UserInfoBean) request.getSession().getAttribute("user") != null){
				request.getSession().removeAttribute("user");
			    request.getSession().removeAttribute("name");
			    request.getSession().removeAttribute("userId");
			    
			
			}
			else{
				request.getSession().setAttribute("user", null);
				request.getSession().setAttribute("name",null);
				request.getSession().setAttribute("userId",null);
			}

		
			 response.sendRedirect("index.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
